-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Build in a temporary directory #4968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build in a temporary directory #4968
Conversation
Per the gulp documentation[1], globs passed to gulp.src should use '/' as the path separator regardless of the path separator used on whatever OS we are running on. [1] https://gulpjs.com/docs/en/getting-started/explaining-globs#segments-and-separators
Make the destination directories for certain build/package/release steps more easily (and centrally) configurable. This only deals with building *_compressed* files; blockly_uncompressed.js and the various msg/js/*.js files are not affected by this commit.
I have verified that npm run build && npm run package produces an identical dist/ directory compared to the one produced prior to this and the previous commit.
There are some files in msg/json/ (currently en.json, qqq.json,
constants.json and synonyms.json) that are generated by
scripts/i18n/js_to_json.py as part of the language file build process
- but this only needs to be done when messages.js is updated and
and usually requires some manual cleanup, so remove this step from the
existing buildLangfiles gulp script and create a separate command
('npm run generate:langfiles') to do this when required.
This is to allow built files to be checked in.
You can now do npm run clean:buildDir, ... clean:releaseDir, or just ... clean, which does both. The release directory is automatically cleaned before packaging commences.
The documented release process is to do npm run recompile, merge the resulting branch to develop, and then do npm run relase, which does not do another build. This process should probably be changed, but for the moment ensure that npm run recompile (as well as npm run package:beta) runs buildTasks.checkinBuilt after each .build to preserve the old procedure.
Don't try to lint built/.
- Do not run npm install. - Do not re-run build that has already been run by a previous test. - Check files in built/ instead repo root. - Fix formatting, styleguide issues.
* Modify scripts/gulpfiles/typings.js to write typings to BUILD_DIR. * Modify tests/scripts/compile_typings.sh to check compilability of resulting output from BUILD_DIR. * Rename checkin script to checkin:built, add a checkin:typings script to do the same for .d.ts files, and a new checkin script to do both. * Have recompile run checkin:typings.
N.B. can't run typings.typings and typings.msgTypings in parallel yet because the latter depends on the existence of an output directory created by the former.
moniika
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re: Test Coverage Section:
- I have an alias for untracking build produces using
git update-index. I also have listed blockly_uncompressed.js, msg/js/* and msg/json/*. I'm not sure if those should also be considered.
Re: Is there documentation on npm release scripts?
- We don't have documentation on our release scripts in core, aside from the jsdoc in the source files. Blockly Samples does have documentation (https://github.com/google/blockly-samples/blob/master/scripts.md) and I think it would be worth it to add something similar to core.
Appengine:
- Feel free to ping me about question about the
appengine_tasks.jsscript. I have the most familiarity with that script on the team. - The appengine script copies the checked in files and also uses local files.
The local files used are: version from package.json and playground dependencies in ./node_modules. (some discussion on that here: #4591 (comment))
Misc notes:
- I like the addition of a config file, rather than having constants at the top of the scripts.
- This may change in the upcoming quarter, but we have needed to update compressed during the quarter, so we might want to document the case when build artifacts should be updated more officially and that
npm checkinshould be used (assuming that is the solution)
The files in The files in I was wondering about whether the tests depended on
I can add some. Where should it such an
That is… funky. What are we doing that is not compatible with App Engine's automatic installation of depedencies (in the standard node environment, at least)?
One minor issue: that there are a few shell scripts that need the same configuration constant, and I've not thought of a good way to have them read from
Yes. I am hoping someone can help me update the release documentation appropriately. |
I've filed #4983 to track adding the
The project deployed on appengine is not a node.js service (there is no package.json), so the dependencies aren't automatically installed. The structure on appengine is that the core repository is copied over into a If you want to take a better look at what the generated directory and included files for appengine look like, you can comment out the the deployAndClean step of the deployDemos script and look at the |
Transcribed (with tweaks) from PR RaspberryPiFoundation#4986.
rachel-fenichel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few small comments, but it looks like Monica has been very thorough.
There is a question about how packaging and releasing ought to work. I initially modified the package script to pull from BUILD_DIR instead of the repository root, but after looking at the recompile and publish tasks I changed this back so as to not change how the release process works. I'm not sure which is preferable:
The advantage of the present arrangement, where we package and release checked-in build products, is that it very easy to see (and test) exactly what will be packaged/released in advance of doing the release.
The disadvantage is that we run the risk of packaging and releasing out-of-date build products. This is especially a risk as none of the automated tests actually test the checked-in build products (with one minor exception: prior to this PR, tests/scripts/compile_typings.sh did actually check the generated .d.ts files in typings/ would compile).
Overall I think it would be better to move to a process that does build, test, package, and release all in a single step, but I do not have much experience in this area to refer to and would appreciate input.
I agree that build->test->package->release is ideal, and also that it doesn't have to be fixed in this PR. I propose that we update the documentation for our day of releasing tasks to include the command needed to rebuild and check in the generated files, which at least reduces the risk of packaging the wrong files.
The .js.map files generated by buildCompressed, buildBlocks etc. were not being copied back by checkinBuilt.
- Reconfigure package_tasks.js to use BUILD_DIR from config.js
(i.e., build/) rather than repository root as source of files to
package.
- Add check to packageTasks.package to ensure that certain required
files exist in BUILD_DIR, to verify that buildTasks.build and
typings.typings have been run.
- Fix packageUMDBundle to use generated, rather than checked-in
version of en.js.
- Fix packageDTS to use the generated (rather than checked-in)
versions of blockly.d.ts and msg/*.d.ts.
- Modify run_all_tests.sh to run packageTasks.package before running
node tests, since they depend on it. Previously this was only
working because 'npm install' runs the 'prepare' script, which would
run the 'package' script - so the code being tested by the node tests
was not the current source but whatever precomipled code had
previously been checked in.
- Remove the 'prepare' script from package.json, since it is no longer
needed (and is now broken, since it requires that build and typings
have been done first.) Note that no scripts at all are included in
the version of package.json that is created in dist/ and subsequently
included in the published npms, so this deletion does not affect what
happens when the Blockly npm in installed - it only affects what
happens when 'npm install' is run after the blockly repo is cloned.
- Factor out the actual recompilation steps from releaseTasks.recompile.
- Rename releaseTasks.recomple to recompileDevelop, since it deals
specifically with the develop branch. (The npm script name is
unchanged.)
- Ensure that a full recompile and repackage is done before publishing
(beta and non-beta) npms.
Per discussion in PR RaspberryPiFoundation#4968, the dirname "build" is widely used for this purpose.
|
Because the node tests depend on the contents of
This all means it's not strictly necessary to run @maribethb: Can you have a look at the changes to in @samelhusseini: I'd appreciate you have a close look at this whole PR but especially the changes to I believe that this it otherwise ready to merge. |
I had forgotten that I needed to change the value of BUILD_DIR in several different places. Added comments warning future editors about this as well as filing issue RaspberryPiFoundation#5007 to track fixing this properly. Despite being misconfigured and therefore failing, the typescript and metadata test scripts were exiting with status 0, indicating successful completion. These have been fixed so they should fail on any error, including misconfiguration.
Fix conflict in package.json.
|
Realised I'd not finished the @rachel-fenichel and @moniika: would you like to review the additional changes since your previous reviews? |
| '!typings/blockly.d.ts', // Exclude checked-in copy of blockly.d.ts. | ||
| 'typings/msg/msg.d.ts', | ||
| ]; | ||
| const builtSrcs = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean that there are actually two versions of typings being included?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two sets of typings: handwritten ones, and generated ones. The latter includes (only) blockly.d.ts and the various msg/*.d.ts files; all the rest are handwritten.
Previously they were all pulled from the same place—typings/—but now the generated ones are pulled from build/ instead. But there's still checked-in copies of the generated ones in typings/, and we want to exclude those (because they might be out-of-date if npm run checkin:typings hasn't been run recently) in favour of the generated ones.
So there are two versions, but only one is being included in the npm.
samelhusseini
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize this is late, but LGTM.
The basics
The details
Proposed Changes
Modify the
build,typingsandtestnpm scripts so that they do not overwrite any checked-in file(s). Specifically, separatebuildinto three separate scripts:npm run generate:langfiles, to be invoked manually after making changes tomsg/messages.js, will runjs_to_json.pyto updatemsg/json/*.json.npm run buildwill do the rest of the build process but write the output toBUILD_DIR(configured to beblockly/built/, but could be anywhere).npm run checkin:builtwill copy the built files fromBUILD_DIRto the repository root so they can be committed.The
typingsnpm script is similarly revised to write toBUILD_DIR, and acheckin:typingsscript provided to copy the results back totypings/. Acheckinscript will runcheckin:builtandcheckin:typings.Modify the scripts run by
npm testso that, where they depend on built files, they use the copies inBUILD_DIRinstead of the the checked-in ones in the repository root.Modify the
recompilescript to runcheckin:builtandcheckin:typings.Provide
clean,clean:buildandclean:releasescripts to wipe thebuild/anddist/temporary directories, and arrange for these to be executed at appropriate points by theBehavior Before Change
npm run buildandnpm testwould modify committed files.Behavior After Change
npm run buildandnpm testshould not modify committed files, butnpm checkincan be used to request such modifications.Reason for Changes
npm run buildornpm testmodify tracked files is surprising and makes it difficult to understand what changes are intentional and which are fallout from previous commits.blockly_compressed.jsandmsg/js/*.jsfrom the repository in future if we want to.Test Coverage
This has been manually tested locally, including by removing all the checked-in build products (that I know about!) via
but I'm not in a position to fully verify the changes to
scripts/gulpfiles/release_tasks.js.Documentation
TBD. These changes ought to be documented somewhere. Is there documentation for our existing npm scripts somewhere?
Additional Information
Release process
There is a question about how packaging and releasing ought to work. I initially modified the
packagescript to pull fromBUILD_DIRinstead of the repository root, but after looking at therecompileandpublishtasks I changed this back so as to not change how the release process works. I'm not sure which is preferable:tests/scripts/compile_typings.shdid actually check the generated.d.tsfiles intypings/would compile).Overall I think it would be better to move to a process that does build, test, package, and release all in a single step, but I do not have much experience in this area to refer to and would appreciate input.
Appengine
I've not looked in detail at
scripts/gulpfiles/appengine_tasks.js; AFAICT it will still use checked-in build products. I would appreciate input from anyone more familiar with the Appengine deploy procedure about how this should be handled.